package logic

import (
	"context"
	"user_srv/model/mysql"

	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type CreateUserRealNameLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCreateUserRealNameLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateUserRealNameLogic {
	return &CreateUserRealNameLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CreateUserRealNameLogic) CreateUserRealName(in *user.CreateUserRealNameRequest) (*user.CreateUserRealNameResponse, error) {
	// todo: add your logic here and delete this line
	name := mysql.UserRealName{
		UserId:   uint(in.UserId),
		RealName: in.RealName,
		IdCard:   in.IdCard,
	}
	err := name.Create()
	if err != nil {
		logx.Error("用户实名失败", err)
		return nil, err
	}
	return &user.CreateUserRealNameResponse{}, nil
}
